package model;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Patient 
{
	private String patientID;
    private String name;
    private String race;
    private String gender;
    private String insurer;
    private String dob;
    private String bloodType;
    private String religion;
    private String country;
    private String state;
    private String city;
    private String postalCode;
    private String address;

	//p.PatientID AS PatientID, p.FirstName AS FirstName, p.LastName AS LastName, p.MiddleInitial, p.Race, p.Gender, " + 
	//"p.Insurer, p.DateOfBirth, p.BloodType, p.Religion, p.Country, p.StateProvince, p.City, p.PostalCode, p.Address,
	
	//TODO figure out how to have patient Medications list and Dosage list
    public Patient(String patientID, String firstName, String lastName, String middleInitial, String race, String gender, 
    		String insurer, String dob, String bloodType, String religion, String country, String state, String city, 
    		String postalcode, String address)
    {
        this.patientID = patientID;
        this.name = firstName + " " + middleInitial + "" + lastName;
        this.race = race;
        this.gender = gender;
        this.insurer = insurer;
        
        try 
        {
        	DateFormat inputFmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
        	Date date = inputFmt.parse(dob);

        	DateFormat outputFmt = new SimpleDateFormat("MM-dd-yyyy");
        	dob = outputFmt.format(date);
		} catch (ParseException e) 
		{
			e.printStackTrace();
		}
        
        this.dob = dob;
        this.bloodType = bloodType;
        this.religion = religion;
        this.country = country;
        this.state = state;
        this.city = city;
        this.postalCode = postalcode;
        this.address = address;
    }
      
    public Patient(String firstName, String middleInitial, String lastName, String gender, 
    		String bloodType, String dob, String address, String city, String state, String postalCode, String patientID)
    {
    	this.patientID = patientID;
        this.name = lastName+ ", " + firstName + " "+  middleInitial + ".";
        this.gender = gender;
        this.bloodType = bloodType;
        
        try 
        {
        	DateFormat inputFmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
        	Date date = inputFmt.parse(dob);

        	DateFormat outputFmt = new SimpleDateFormat("MM-dd-yyyy");
        	dob = outputFmt.format(date);
		} catch (ParseException e) 
		{
			e.printStackTrace();
		}
        this.dob = dob;
        if (address.length() != 0)
        {
        	this.address = address + "<br>" + city + ", "+ state + " " + postalCode;
        }
        else
        	this.address = address;
    }

	public String getPatientID() 
	{
		return patientID;
	}
	public void setPatientID(String patientID) 
	{
		this.patientID = patientID;
	}
	
	public String getName() 
	{
		return name;
	}
	public void setName(String firstName, String middleInitial, String lastName) 
	{
		this.name = lastName+ ", " + firstName + " "+  middleInitial + ".";
	}
	
	public String getRace() 
	{
		return race;
	}
	public void setRace(String race) 
	{
		this.race = race;
	}
	
	public String getGender() 
	{
		return gender;
	}
	public void setGender(String gender) 
	{
		this.gender = gender;
	}
	
	public String getInsurer() 
	{
		return insurer;
	}
	public void setInsurer(String insurer) 
	{
		this.insurer = insurer;
	}
	
	public String getDOB() 
	{
		return dob;
	}
	public void setDOB(String dob) 
	{
		this.dob = dob;
	}
	
	public String getBloodType() 
	{
		return bloodType;
	}
	public void setBloodType(String bloodType) 
	{
		this.bloodType = bloodType;
	}
	
	public String getReligion() 
	{
		return religion;
	}
	public void setReligion(String religion) 
	{
		this.religion = religion;
	}
	
	public String getCountry() 
	{
		return country;
	}
	public void setCountry(String country) 
	{
		this.country = country;
	}
	
	public String getState() 
	{
		return state;
	}
	public void setState(String state) 
	{
		this.state = state;
	}
	
	public String getCity() 
	{
		return city;
	}
	public void setCity(String city) 
	{
		this.city = city;
	}
	
	public String getPostalCode() 
	{
		return postalCode;
	}
	public void setPostalCode(String postalCode) 
	{
		this.postalCode = postalCode;
	}
	
	public String getAddress() 
	{
		return address;
	}
	public void setAddress(String address) 
	{
		this.address = address;
	}

}
